package com.brainydroid.framework;

import java.util.ArrayList;

import com.badlogic.gdx.Audio;
import com.badlogic.gdx.audio.Sound;
import com.badlogic.gdx.files.FileHandle;




public class AudioManager {
	
	Scene scene_;
	Audio audio_;
	ArrayList<Sound> sounds_;
	ArrayList<Object> objects_; // array of objects where objects are sorted by display order

	public AudioManager(Scene s, Audio a) {
		scene_ = s;
		audio_ = a;
		sounds_ = new ArrayList<Sound>();
		objects_ = s.objects_;
	}
	
	public Sound addSound(FileHandle sound) {
		sounds_.add(audio_.newSound(sound));
		return sounds_.get(sounds_.size()-1);	
		//return audio_.newSound(sound);
		}
	
	public void sortObjects() {
		objects_ = null;
		objects_ = new ArrayList<Object>(scene_.objects_.size());
		for(Object o: scene_.objects_) objects_.add(o);
	}

	public void playSound() {
		for (Object o : objects_){
			if (o.play_sound){
	//			o.sound_.play(1);
				o.play_sound = false;
			}
		}
	}
	
	
}